import threading
from queue import Queue

Lock = threading.Lock()

    
__queue = {}

  
def put(name,o):
    
    try:
        Lock.acquire()
        if name not in __queue:
            __queue[name] = Queue()
        __queue[name].put(o)
        try:
            print("[hook][lianjia]:添加hook列表，对列长度"+str(__queue[name].qsize()))
        except:
            pass
    finally:
        Lock.release()
    
    
def get(name):
    while True:
        try:
            Lock.acquire()
            if name not in __queue:
                __queue[name] = Queue()
            o = __queue[name].get(block = True, timeout = 1)
            print("[hook][lianjia]:消费hook列表，对列长度"+str(__queue[name].qsize()))
            return o
        except:
            pass
        finally:
            Lock.release()
        
        
        